﻿
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>WebGL Test</title>
    <link rel="stylesheet" href="app.css" type="text/css" />
    <link rel="stylesheet" href="lighttool/lt_htmlui.css" type="text/css" />
    <script src="lighttool/lt_jsloader.js"></script>
    <script src="app.js"></script>
    <script src="FileHelper.js"></script>
    <script id="vs" type="x-shader/x-vertex">

        attribute vec3 position;
        attribute vec3 normal;
        attribute vec2 uvtex;
        uniform   mat4 mvpMatrix;
        uniform   mat4 invMatrix; 
        uniform   vec3 lightDirection;
        uniform   vec4 ambientColor;
        varying vec4 vColor; 
        varying vec2 vuvtex;
        void main(void){
            vec3  invLight = normalize(invMatrix * vec4(lightDirection, 0.0)).xyz;
            float diffuse  = clamp(dot(normal, invLight), 0.1, 1.0);
            gl_Position = mvpMatrix * vec4(position, 1.0);
            vColor = vec4(vec3(diffuse), 1.0) + ambientColor;;
            vuvtex = uvtex;
        }
    </script>
    <script id="fs" type="x-shader/x-fragment">
        precision mediump float;
        uniform sampler2D texture;
        varying vec4 vColor;
        varying vec2 vuvtex;
        void main(void){
            gl_FragColor = vColor * texture2D(texture, vuvtex);
        }
          
    </script>
</head>
<body>
    <canvas id="canvas"></canvas>
    <div id="panel" class="full" style="top:0px;margin:0px;"></div>
</body>
</html>
